home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5236 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.1 KB  |  45 lines

  1. Path: allmalt.cs.uwm.edu!kumbera
  2. From: kumbera@allmalt.cs.uwm.edu (Mike Kumbera)
  3. Newsgroups: comp.lang.c++
  4. Subject: problem initializing static member of a class.
  5. Date: 3 Feb 1996 04:06:18 GMT
  6. Organization: Computer Science University of Wisconsin-Milwaukee
  7. Message-ID: <4eumvq$ko1@uwm.edu>
  8. NNTP-Posting-Host: 129.89.139.2
  9.  
  10. I'm having troubles getting a static initilaizer for a member
  11.  of a class working.  I want to declare a static array of pointers
  12.  to a class as a member of the class.
  13. (If this is possible)
  14.  
  15. The following code is a short example of what I'm trying to do:
  16.  
  17.  
  18. ------------------------------------------------------------
  19.  
  20. #include <iostream.h>
  21.  
  22. class TEST
  23. {
  24.    // a static array of pointers to the class TEST
  25.    static TEST *TEST_ptr[];
  26. };
  27.  
  28. // initialize the static member (I can't get this working)
  29. TEST *TEST::TEST_ptr[] = NULL;
  30.  
  31. main()
  32. {
  33.    TEST a;
  34. }
  35.  
  36.  
  37. ------------------------------------------------------------
  38.  
  39. When I compile the code with gcc I get:
  40. help.C:10: invalid initializer
  41.  
  42. ANY ideas would be appreciated...
  43.  
  44. mkumbera@cs.uwm.edu (Michael Kumbera)
  45.